package com.ywjh.inter.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ywjh.inter.conn.DBConnection;
import com.ywjh.inter.entity.InsulinPenMedicineEntity;
import com.ywjh.inter.dao.InsulinPenMedicineDAO;

public class InsulinPenMedicineService {
	
	private static InsulinPenMedicineService instance;
	private InsulinPenMedicineDAO insulinPenMedicineDAO;
	
	public static InsulinPenMedicineService getInstance() {
		if(instance == null) {
			instance = new InsulinPenMedicineService();
			instance.insulinPenMedicineDAO = new InsulinPenMedicineDAO();
		}
		return instance;
	}

	public List<InsulinPenMedicineEntity> list() {
		List<InsulinPenMedicineEntity> b = new ArrayList<>();
		Connection conn = null;
		try {
			conn = DBConnection.getDBConnection();
			b = insulinPenMedicineDAO.list(conn);
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		} finally {
			DBConnection.close(conn);
		}
		return b;
	}
}
